
package thinkinginjava.concurrency;

/**
 * Demonstration of Runnable interface  
 * @author qinchong
 */
public class LiftOff implements Runnable {
    protected int countDown = 10;//default
    protected static int taskCount = 0;
    protected final static int id = taskCount++;

    public LiftOff() {
    }

    public LiftOff(int countDown) {
        this.countDown = countDown;
    }

    @Override
    public void run() {
        while (countDown-- > 0) {
            System.out.println(status());
            Thread.yield();
        }
    }

    protected String  status() {
        return "#"+id+"("+(countDown>0?countDown:"LiftOff")+")";
    }
}
